<template>
  <div>
    <h1>pinia</h1>
    <from-pinia></from-pinia>
    <p>++++++++++++++++++</p>
    <to-pinia></to-pinia>

    <h1>Emp</h1>
    <!-- 编程式路由 -->
    <button @click="todept">部门管理</button>
  </div>
</template>

<script setup>
import { useRouter } from 'vue-router'

import FromPinia from '../pinia/FromPinia.vue'
import ToPinia from '../pinia/ToPinia.vue'

const deptno = '2'
const router = useRouter()
// const x = 1
// const y = 2

const todept = () => {
  //   router.push('/dept')  error : 废弃的方法
  //   router.push({ name: 'dept', params: { username: 'eduardo' } })
  //   router.push({ name: 'dept', query: { plan: 'private' } })
  //   router.push({ path: 'dept', hash: '#team' })
  //   router.push(`/dept/${username.value}`) // -> /user/eduardo
  //   router.push({ name: 'dept', params: { username } })
  //   router.push({ name: 'dept', params: { username } }) // -> /user/eduardo
  //   router.replace({ path: '/dept' })
  router.push({ name: 'dept', params: { deptno: deptno } }) // -> /dept/1
}
</script>
